package bean;

import entity.Course;
import java.util.*;
public class Student extends Person {
    private final List<Course> selectedCourses = new ArrayList<>();

    public Student(String id, String name, String gender) {
        super(id, name, gender);  

    public void selectCourse(Course course) {
        if (course == null) return;
        if (selectedCourses.contains(course)) {
            System.out.println(name + " 已选过 " + course.getName());
            return;
        }
        selectedCourses.add(course);
        System.out.println(name + " 选了 " + course.getName()
                + "（授课教师：" + course.getTeacherName() + "）");
    }

    public void dropCourse(Course course) {
        if (course == null) return;
        boolean ok = selectedCourses.remove(course);
        System.out.println(ok ? name + " 退了 " + course.getName()
                              : name + " 未选 " + course.getName() + "，无法退课");
    }

    
    @Override
    protected void printDetail() {
        if (selectedCourses.isEmpty()) {
            System.out.println("当前未选课");
            return;
        }
        selectedCourses.forEach(System.out::println);
    }
}
